from brain import Zone
import random
from dataclasses import dataclass, field
import dataclasses_json


@dataclass
class CellGroup(dataclasses_json.DataClassJsonMixin):
    def __init__(self) -> None:
        self.group_input_zone: Zone = None
        self.group_output_zone: Zone = None
        self.cell_input_radius: float
        self.cell_output_radius: float
        self.cell_qty: int
        self.input_qty_per_cell: int
        self.output_qty_per_cell: int


@dataclass
class Egg(dataclasses_json.DataClassJsonMixin):
    cell_group_qty: int = field(default=30, init=False)

    def __init__(self) -> None:
        self.brain_radius: float = 1000
        self.cell_groups: list[CellGroup] = []

    def create_brand_new_egg():
        egg = Egg()
        for i in range(Egg.cell_group_qty):
            cell_group = CellGroup()
            cell_group.group_input_zone = Zone(
                random.random() * egg.brain_radius,
                random.random() * egg.brain_radius,
                random.random() * egg.brain_radius * 0.01,
            )
            cell_group.group_output_zone = Zone(
                random.random() * egg.brain_radius,
                random.random() * egg.brain_radius,
                random.random() * egg.brain_radius * 0.01,
            )
            cell_group.cell_qty = random.randint(1, 10)
            cell_group.cell_input_radius = random.random() * 0.001
            cell_group.cell_output_radius = random.random() * 0.001
            cell_group.input_qty_per_cell = random.randint(1, 10)
            cell_group.output_qty_per_cell = random.randint(1, 5)
            egg.cell_groups.append(cell_group)
        return egg
